package com.ittest.service.store.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ittest.domain.store.City;
import com.ittest.domain.store.City;
import com.ittest.factory.MapperFactory;
import com.ittest.mapper.store.CityMapper;
import com.ittest.service.store.CityService;
import com.ittest.utils.TransactionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CityServiceImpl implements CityService {
    @Override
    public List<City> findAll() {
        SqlSession sqlSession = null;
        List<City> list = null;
        try {
            //获取sqlSession
            sqlSession = MapperFactory.getSqlSession();
            //获取Mapper代理对象
            CityMapper cityMapper = MapperFactory.getMapper(sqlSession, CityMapper.class);
            list = cityMapper.findAll();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //释放资源
            if (sqlSession!=null) {
                TransactionUtil.close(sqlSession);
            }
        }
        return list;
    }
}
